Advanced logging techniques

remotemanager comes with an inbuilt logging system who’s Handler is accessible via the remotemanager.Logger attribute

these functions are limited, however useful for debugging and it may be helpful to have a block at the top of any notebooks in testing that sets some variables

A common use case is to place a block at the start of a notebook, dictating the intended log path and the parameters, as follows:

[1]:
import remotemanager

remotemanager.Logger.level = 'debug'
remotemanager.Logger.path = 'notebook_to_test_feature'
remotemanager.Logger.overwrite = True

Properties to set

Below is a quick summary of the available properties. See the Logging documentation for full info

As these are properties, they can be set or queried. For example, set and read the logging level with

[2]:
remotemanager.Logger.level = 'warning'
remotemanager.Logger.level
[2]:
'WARNING'

Logger.level

This allows you to set the logging level which will be used. Defaults to WARNING. Possible options (in order of increasing verbosity) are:

Mode

Adds to the logfile

Critical

Fatal errors only

Error

Damaging errors

Warning

All errors and warnings

Important

Noteworthy non-errors

Info

Important runtime info

Runtime

Runtime information

Debug

All runtime information

Logger.path

Setting the path will firstly point the logger at the intended filepath, and also attempt to delete the previous log, if it is empty. If called before any other actions are taken, essentially moves the log to a new location.

Note

Logs are enforced to be in yaml format, in keeping with the package theme of using yaml files where possible. This has the added benefit of yaml formatting and features

Warning

If the default log path log.yaml already exists and has content in it, it will not be deleted and a warning will be raised. This does not affect downstream runtime, but exists as a safety measure to not delete any logs you may wish to keep with a default name

Logger.overwrite

Setting this to True will set the write mode for the logs to w, overwriting any previous log

Logger.write_mode

Similarly to the previous overwrite property, only allowing you to directly set the write mode of the logging Handler

Useful functions

Logger.refresh()

Calling this function will force delete and re-create the logfile

Logger.debug()

This function, along with its companions, allows direct access to the log. Calling this will place a log message in the log under the caller EXTERNAL. For example:

[3]:
remotemanager.Logger.info('this will a log message at the level "info"')
remotemanager.Logger.warning('this will a log message at the level "warning"')

These exist for all log levels as listed above